package com.SoftwareManage.service.impl;

import com.SoftwareManage.dao.RoleDao;
import com.SoftwareManage.entity.Role;
import com.SoftwareManage.entity.RolePermission;
import com.SoftwareManage.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleDao roleDao;
    @Override
    public List<Role> selectAll() {
        return roleDao.selectAll();
    }

    @Override
    public List<RolePermission> selectAlls(int page, int pageSize) {
        return roleDao.selectAlls(page,pageSize);
    }

    @Override
    public List<String> selectRolePermissions(int id) {
        return roleDao.selectRolePermissions(id);
    }

    @Override
    public List<Role> search(String role_name) {
        return roleDao.search(role_name);
    }

    @Override
    public List<RolePermission> searchs(String role_name, int page, int pageSize) {
        return roleDao.searchs(role_name, page, pageSize);
    }

    @Override
    public void update(int id,String role_name, String remark) {
        roleDao.update(id,role_name, remark);
    }

    @Override
    public void deleteRolePermission(int role_id) {
        roleDao.deleteRolePermission(role_id);
    }

    @Override
    public void addRolePermission(int role_id, int permission_id) {
        roleDao.addRolePermission(role_id,permission_id);
    }

    @Override
    public List<String> selectAllRoles() {
        return roleDao.selectAllRoles();
    }

    @Override
    public void addRole(String role_name, String remark) {
        roleDao.addRole(role_name, remark);
    }

    @Override
    public Role selectRole(String role_name) {
        return roleDao.selectRole(role_name);
    }

    @Override
    public void deleteRole(int role_id) {
        roleDao.deleteRolePermission(role_id);
        roleDao.deleteRole(role_id);
    }
}
